﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using MediaMonitor.Common;
using System.IO;

namespace MediaMonitor.admin
{
    public partial class Newspdf_popup : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
               

                if (!String.IsNullOrEmpty(Request.QueryString["id"]))
                {
                    String ReturnValue = Request.QueryString["id"].ToString();
                   
                    //Show Image
                    if ((ReturnValue.Contains("jpg")) || (ReturnValue.Contains("JPG")) || (ReturnValue.Contains("jpeg")) || (ReturnValue.Contains("JPEG")))
                    {
                        string image = Request.QueryString["id"].ToString();
                        if (File.Exists(Server.MapPath("News/FullPage/" + image)))
                        {
                            Img.ImageUrl = "News/FullPage/" + Request.QueryString["id"].ToString();
                            Img.Visible = true;
                        }
                        else
                        {
                            lblErrorMsg.Text = "Sorry,the file does not exist..!!";
                        }
                       
                    }
                    //Show Video
                    else if ((ReturnValue.Contains("wmv")) || (ReturnValue.Contains("WMV")) || (ReturnValue.Contains("wma")) || (ReturnValue.Contains("WMA")))
                    {
                         StringBuilder StringCon = new StringBuilder();
                         StringCon.Clear();
                         StringCon.Append("<object classid='clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6' id='Player1' width='424' height='379'>");
                         StringCon.Append("<param name='URL' value='News/FullPage/" + ReturnValue + "'>");
                         StringCon.Append("<param name='News/FullPage/" + ReturnValue + "'>");
                         StringCon.Append("<param name='AutoStart' value='1'>");
                         StringCon.Append("<param name='ShowControls' value='1'>");
                         StringCon.Append("<param name='ShowStatusBar' value='1'>");
                         StringCon.Append("<param name='ShowDisplay' value='1'>");
                         StringCon.Append("<param name='stretchToFit' value='1'>");
                         StringCon.Append("<embed type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/'");
                         StringCon.Append("width='424' height='379' src='News/FullPage/" + ReturnValue + "'");
                         StringCon.Append("filename='News/FullPage/" + ReturnValue + "'");
                         StringCon.Append("autostart='1' showcontrols='1' showstatusbar='1' showdisplay='1'>");
                         StringCon.Append("</embed>");
                         StringCon.Append("</object>");
                         myObject.Text = StringCon.ToString();
                        

                    }
                   

                }

                if (!String.IsNullOrEmpty(Request.QueryString["FTD"]))
                {
                    String FTD = Request.QueryString["FTD"].ToString();
                    if (File.Exists(Server.MapPath("News/FullPage/" + FTD)))
                    {
                        Utility.DownloadFile("~/News/FullPage/" + FTD, true);
                    }
                    else {
                        lblErrorMsg.Text = "Sorry,the file does not exist..!!";
                    }
                  
                }
            }

        }
    }
}